package Price;

use Movie;
use Moose;
use feature qw(switch);

sub get_price_code {
	die "Must be implemented by subclass";
}

sub get_charge {
    my $self = shift;
    my $days_rented = shift;
    my $result = 0;
    given ($self->get_price_code()) {
        when($Movie::REGULAR) {
            $result = 2;
            if ($days_rented > 2) {
                $result += ($days_rented - 2) * 1;
            }
        }
        when($Movie::NEW_RELEASE) { $result = $days_rented * 3 }
        when($Movie::CHILDREN) {
            $result = 1;
            if ($days_rented > 3) {
                $result += ($days_rented - 3) * 1;
            }
        }
    }
    return $result;
}

package Childrenprice;
use Moose;

extends 'Price';

sub get_price_code {
	return $Movie::CHILDREN;
}

package Newreleaseprice;
use Moose;

extends 'Price';

sub get_price_code {
	return $Movie::NEW_RELEASE;
}

package Regularprice;
use Moose;

extends 'Price';

sub get_price_code {
	return $Movie::REGULAR;
}


